package st.business.tepth.business.visitor.visitorwork.work.detail;

import st.business.tepth.base.OnDataConvertListener;
import st.business.tepth.business.visitor.visitorwork.entity.WorkDetailBean;

/**
 * Author: shadow
 * Email:  1025431817@qq.com
 * Time:   2019-06-05 17:33
 */

public class DetailPresenter extends DetailContract.Presenter {
    private final DetailContract.View mView;
    private final DetailContract.Model mModel;

    public DetailPresenter(DetailContract.View view) {
        mView = view;
        mModel = new DetailModel();
    }

    @Override
    void getWorkDetail(String token, int repairTaskId) {
        addDisposable(mModel.getWorkDetail(token, repairTaskId,
                new OnDataConvertListener<WorkDetailBean>() {
                    @Override
                    public void convert(WorkDetailBean workDetailBean) {
                        if (mView != null) {
                            mView.showWorkDetail(workDetailBean);
                        }
                    }

                    @Override
                    public void error(int code, String msg) {
                        if (mView != null) {
                            mView.showWorkDetail(null);
                        }
                    }
                }));
    }
}
